package com.itheima.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.dao.OrderDetailDao;
import com.itheima.pojo.OrderDetail;
import com.itheima.service.OrderDetailService;
import com.itheima.service.OrderService;
import org.springframework.stereotype.Service;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.URLEncoder;

@Service
public class OrderDetailServiceImpl extends ServiceImpl<OrderDetailDao, OrderDetail> implements OrderDetailService {
    @Override
    public void export(HttpServletResponse response) {

    }
//    public static void downloadTempalate(HttpServletResponse response) throws IOException {
//        // 告诉浏览器用什么软件可以打开此文件
//        response.setHeader("content-Type", "application/vnd.ms-excel");
//        // 下载文件的默认名称
//        response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("订单明细.xlsx", "utf-8"));
//        //4. 创建输入、输出流
//        FileInputStream input = new FileInputStream(GlobalSet.download_url);
//        ServletOutputStream sos = response.getOutputStream();
//
//        //IO流获取文件的字节流，然后再响应给浏览器
//        byte[] arr = new byte[1024];
//        int res = 0;
//        while((res = input.read(arr)) > 0){
//            //将读取的内容输出到输出流中
//            sos.write(arr, 0, res);
//        }
//
//        input.close();
//        sos.close();
//    }
}
